﻿/*公共js库*/

/*弹层公共JS方法*/
var Popup = {
    /*
    /// <summary>
    /// 成功提示
    /// </summary>
    /// <param name="Msg">提示消息</param>
    /// <param name="callback">回调函数</param>
    */
    Success: function (Msg, callback) {
        noticePup({ text: Msg, callback: callback || null }).success();
    },
    /*
    /// <summary>
    /// 错误提示
    /// </summary>
    /// <param name="Msg">提示消息</param>
    */
    Error: function (Msg) {
        noticePup({ text: Msg }).error();
    },
    /*
    /// <summary>
    /// 确定，取消提示
    /// </summary>
    /// <param name="Msg">提示消息</param>
    */
    Confirm: function (Msg, callback) {
        var _bool;
        noticePup({
            text: Msg,
            "callback": function (bool) {
                if (callback)
                    callback(bool);
            }
        }).global();
    },
    /*
    /// <summary>
    /// 显示指定弹层元素，并指定关闭该弹层的元素
    /// </summary>
    /// <param name="elemID">弹层元素</param>
    /// <param name="closeID">关闭单层元素</param>
    */
    proPup: function (elemID, closeID) {
        elemID.css("display", "block");
        closeID.click(function () {
            elemID.css("display", "none");
            closeID.unbind("click");
        })
    },
    /*
    /// <summary>
    /// 淡入指定弹层元素,并在500毫秒后淡出该元素
    /// </summary>
    /// <param name="elem">弹层元素</param>
    */
    txt: function (elem) {
        elem.fadeIn(500).delay(500).fadeOut(500);
    }
};


var Ajax = {
    Post: function (RequestUrl, params, successfunc, errorfunc) {
        //给参数加上时间戳，防止缓存
        params["RandomTime"] = new Date().getTime();
        $.ajax({
            url: RequestUrl,
            type: "POST",
            data: params,
            dataType: "json",
            success: successfunc,
            error: errorfunc || null
        });
    }
};

//过滤特殊字符
function checkSpecialChar(s) {
    var char = new Array('*', '-', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '\'', '"', ';', ':');
    for (var i = 0; i < char.length; i++) {
        if (s.indexOf(char[i]) > -1) {
            return true;
        }
    }
    return false;
}

// 获取字符串的长度 一个汉字为2个字符 
function getTextLength(str) {
    return str.replace(/[^\x00-\xff]/g, "xx").length;
};

//QQ验证
function check_QQ(str) {
    var qq = str;
    if (qq != "") {
        if (qq.search(/^[0-9]\d{4,}$/) != -1) {
            redflag = 0;
            return true;
        }
        else {
            redflag = 1;
            return false;
        }
    }
}
//msn验证
function check_msn(str) {
    var msn = str;
    if (msn != "") {
        if (msn.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
            redflag = 0;
            return true;
        }
        else {
            redflag = 1;
            return false;
        }
    }

}

